
public class Test {

        public interface RCallback {
                public void onStateChanged(String state);
        }

        private static native void start_server();

        private static native void native_set_callback(RCallback test);

        public void onStateChanged(int state) {
                System.out.println("jni msg: " + state);
        };

        static {
                System.loadLibrary("protocol");
        }

        public static void main(String[] args) {
                System.out.println("执行1");
                new Thread(new Runnable() {

                        @Override
                        public void run() {
                                start_server();
                        }
                }).start();

                native_set_callback(new RCallback() {

                        @Override
                        public void onStateChanged(String state) {
                                System.out.println("hello:" + state);
                        }

                });
                System.out.println("执行2");

        }
}